﻿using System;
using System.Collections.Generic;
using IQToolkit;
using IQToolkit.Data;
using Infrastucture.Factories;
using TimeSplicerModule.DataModels;
using TimeSplicerModule.DomainModels;


namespace TimeSplicerModule.Factories
{
    public interface IUserFactory : Infrastucture.Factories.IFactory<UserDataModel, UserModel>
    {
        UserModel CreateNew(List<StatusModel> statuses, List<ApplicationRoleModel> applicationRoles, List<TeamModel> teams);
        UserModel Get(Func<UserDataModel, bool> where, List<StatusModel> statuses, List<ApplicationRoleModel> applicationRoles, List<TeamModel> teams, List<JobRoleModel> jobRoles);
    }

    // todo: need to add encription on the password

    public class UserFactory : Factory<UserDataModel, UserModel>, IUserFactory
    {
        public UserFactory(DbEntityProvider provider, IEntityTable<UserDataModel> db)
            : base(provider, db)
        {

        }

        public UserModel CreateNew(List<StatusModel> statuses, List<ApplicationRoleModel> applicationRoles, List<TeamModel> teams)
        {
            var model = base.CreateNew();

            model.Statuses = statuses;
            model.ApplicationRoles = applicationRoles;
            model.Teams = teams;


                return model;
        }

        public UserModel Get(Func<UserDataModel, bool> where, List<StatusModel> statuses, List<ApplicationRoleModel> applicationRoles, List<TeamModel> teams, List<JobRoleModel> jobRoles)
        {
            var model = base.Get(where);

            model.Statuses = statuses;
            model.ApplicationRoles = applicationRoles;
            model.Teams = teams;
            model.JobRoles = jobRoles;


            return model;
        }
    }
}
